﻿Imports DAO
Imports DTO
Public Class frmDangKy

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (cbxagree.Checked) Then
            Dim _ND As New NguoiDungDTO()
            Dim ND_DAO As New NguoiDungDAO()
            If (txtmatkhau.Text <> txtmatkhau1.Text) Then
                MessageBox.Show("Mat Khau Khong Trung")
                Return
            End If
            Try
                _ND.USER = txttendangnhap.Text
                _ND.PASS = txtmatkhau.Text
                _ND.HOTEN = txthoten.Text
                _ND.DIACHI = txtdiachi.Text

                _ND.SODIENTHOAI = txtsodienthoai.Text
            Catch ex As Exception
                MessageBox.Show("Du lieu loi")
                Return
            End Try
            Dim SL As Integer = ND_DAO.SoLuong(_ND)
            If (SL >= 1) Then
                MessageBox.Show("Nguoi Dung Da Ton TAi")
                Return
            Else
                Dim kq As Integer = ND_DAO.INSERT(_ND)

                If kq = 1 Then
                    MessageBox.Show("Insert thanh cong")
                Else
                    MessageBox.Show("Insert khong thanh cong")
                End If

            End If
        Else
            MessageBox.Show("click để xác nhận thông tin là chính xác")
        End If


    End Sub

    Private Sub btnthoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoat.Click
        Me.Close()
    End Sub

    Private Sub frmDangKy_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class